package com.x.erp.dao;

import com.x.erp.thirdparty.CityMappingThirdparty;
import com.x.framework.dao.BaseDao;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * 与第三方城市关系映射
 *
 */
@Repository
public class CityMappingThirdpartyDao extends BaseDao{
	
	private final static String selectCityMappingThirdpartyListSql = "SELECT T1.* FROM BASE_CITY_MAPPING_THIRDPARTY T1 WHERE 1=1 ";
	public List<CityMappingThirdparty> selectCityMappingThirdpartyList(CityMappingThirdparty cityMappingThirdparty) throws Exception{
		StringBuilder sb = new StringBuilder(selectCityMappingThirdpartyListSql);
		List<Object> params = new ArrayList<Object>();
		if(this.isString(cityMappingThirdparty.getCityId())){
			sb.append("AND T1.CITY_ID = ? ");
			params.add(cityMappingThirdparty.getCityId());
		}
		if(this.isNotNull(cityMappingThirdparty.getCityThirdpartyId())){
			sb.append("AND T1.CITY_THIRDPARTY_ID = ? ");
			params.add(cityMappingThirdparty.getCityThirdpartyId());
		}
		if(this.isNotNull(cityMappingThirdparty.getProvinceThirdpartyId())){
			sb.append("AND T1.PROVINCE_THIRDPARTY_ID = ? ");
			params.add(cityMappingThirdparty.getProvinceThirdpartyId());
		}
		if(this.isNotNull(cityMappingThirdparty.getCityType())){
			sb.append("AND T1.CITY_TYPE = ? ");
			params.add(cityMappingThirdparty.getCityType());
		}
		return this.queryForList(sb.toString(), CityMappingThirdparty.class, params);
	}

}
